import 'package:flutter_hotwork/Myapplication.dart';

class tasklistbean {
  int code;
  String message;
  List<Taskbean> result;
  bool success;
  int timestamp;

  tasklistbean(
      {this.code, this.message, this.result, this.success, this.timestamp});

  tasklistbean.fromJson(Map<String, dynamic> json) {
    code = json['code'];
    message = json['message'];
    if (json['result'] != null) {
      result = new List<Taskbean>();
      json['result'].forEach((v) {
        result.add(new Taskbean.fromJson(v));
      });
    }
    success = json['success'];
    timestamp = json['timestamp'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['code'] = this.code;
    data['message'] = this.message;
    if (this.result != null) {
      data['result'] = this.result.map((v) => v.toJson()).toList();
    }
    data['success'] = this.success;
    data['timestamp'] = this.timestamp;
    return data;
  }
}

class Taskbean {
  var checkDistance;
  String checkEndTime;
  List<CheckInspectorPos> checkInspectorPos;
  String checkStartTime;
  var checkType;
  var checkName;
  String checkProject;
  String createBy;
  String createTime;
  bool delete;
  String endTime;
  int id;
  String lineId;
  String lineName;
  var period;
  String periodStr;
  String startTime;
  String checkTypeStr;
  int taskStatus;

  String updateTime;

  Taskbean(
      {this.checkDistance,
        this.checkEndTime,
        this.checkInspectorPos,
        this.checkStartTime,
        this.checkType,
        this.checkName,
        this.createBy,
        this.createTime,
        this.delete,
        this.endTime,
        this.id,
        this.lineId,
        this.checkTypeStr,
        this.periodStr,
        this.lineName,
        this.period,
        this.checkProject,
        this.startTime,
        this.taskStatus,
        this.updateTime});

  Taskbean.fromJson(Map<String, dynamic> json) {
    checkDistance = json['checkDistance'];
    checkEndTime = json['checkEndTime'];
    if (json['checkInspectorPos'] != null) {
      checkInspectorPos = new List<CheckInspectorPos>();
      json['checkInspectorPos'].forEach((v) {
        checkInspectorPos.add(new CheckInspectorPos.fromJson(v));
      });
    }
    checkStartTime = json['checkStartTime'];
    checkType = json['checkType'];
    checkName = json['checkName'];
    createBy = json['createBy'];
    createTime = json['createTime'];
    delete = json['delete'];
    checkTypeStr = json['checkTypeStr'];
    endTime = json['endTime'];
    periodStr = json['periodStr'];
    id = json['id'];
    checkProject= json['checkProject'];
    lineId = json['lineId'];
    lineName = json['lineName'];
    period = json['period'];
    startTime = json['startTime'];
    taskStatus = json['taskStatus'];
    updateTime = json['updateTime'];
  }

  int getId(){
    for(int i = 0;i<checkInspectorPos.length;i++){
      if(MyApplication.loginuserinfo.userInfo.username==checkInspectorPos[i].checkUser){
        return checkInspectorPos[i].inspectorId;
      }
    }
  }
  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['checkDistance'] = this.checkDistance;
    data['checkEndTime'] = this.checkEndTime;
    if (this.checkInspectorPos != null) {
      data['checkInspectorPos'] =
          this.checkInspectorPos.map((v) => v.toJson()).toList();
    }
    data['checkStartTime'] = this.checkStartTime;
    data['checkType'] = this.checkType;
    data['checkName'] = this.checkName;
    data['createBy'] = this.createBy;
    data['createTime'] = this.createTime;
    data['delete'] = this.delete;
    data['endTime'] = this.endTime;
    data['id'] = this.id;
    data['checkTypeStr'] = this.checkTypeStr;

    data['checkProject'] = this.checkProject;
    data['lineId'] = this.lineId;
    data['lineName'] = this.lineName;
    data['period'] = this.period;
    data['periodStr'] = this.periodStr;
    data['startTime'] = this.startTime;
    data['taskStatus'] = this.taskStatus;
    data['updateTime'] = this.updateTime;
    return data;
  }
}

class CheckInspectorPos {
  var checkTaskId;
  String checkUser;
  String checkUserName;
  var inspectorId;
  var isDone;

  CheckInspectorPos(
      {this.checkTaskId,
        this.checkUser,
        this.checkUserName,
        this.inspectorId,
        this.isDone});

  CheckInspectorPos.fromJson(Map<String, dynamic> json) {
    checkTaskId = json['checkTaskId'];
    checkUser = json['checkUser'];
    checkUserName = json['checkUserName'];
    inspectorId = json['inspectorId'];
    isDone = json['isDone'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['checkTaskId'] = this.checkTaskId;
    data['checkUser'] = this.checkUser;
    data['checkUserName'] = this.checkUserName;
    data['inspectorId'] = this.inspectorId;
    data['isDone'] = this.isDone;
    return data;
  }
}
